var request = require("request");
var $ = require("../../include/$");
var url = "http://api.map.baidu.com/geosearch/v3/";
var tablename = "store_map";
var geotable_id = 123228;
var ak = "yyvKdot9D7eZZvKsYliWchrg";
module.exports = {
	get: function(req, res) {
		console.log(req.query);
		var qs = {
			region: req.query.city || "深圳",
			ak: ak,
			geotable_id: geotable_id,
			page_index: req.query.page_index || 0
		};
		req.query.page_size ? (qs.page_size = req.query.page_size) : false;
		request.get({
			url: url + "local",
			qs: qs,
			json: true
		}, function(error, response, body) {
			if (response.statusCode == 200) {
				res.send(body);
			} else {
				console.log("failed", error);
				res.send(500, error);
			};
		});
	}
};